<?php
MYTCONN();
mn_field('hidden', 'ED', 'OBJCT_ID', '', '', '', '', '');
mn_field('hidden', 'ED', 'OBJCT_TYPE', '', '', '', '', '');
if (isset($_POST['amh_ID'])) {
    $AMHID = $_POST['amh_ID'];
} elseif (isset($_GET['AMHID'])) {
    $AMHID = $_GET['AMHID'];
} else {
    $AMHID = $GET[1]['amh_ID'];
}
?>
<table width="100%" cellpadding="2" cellspacing="1">
    <tr>
        <td colspan="4" valign="top">Anexos
            <?php mn_field('button', 'ED', 'Enviar ficheiros', 'Anexar ficheiro', '', '', 'False', 'SUBMIT" onclick="modalwindow(\'Upload de Documentos\',\'_response/call.php?get=Compliance/amh_docadd&ID=' . $AMHID . '\',500,300);'); ?>
            <div id="Doc_ActionED"></div></td>
    </tr>
    <tr bgcolor="#D8D8C7">
        <td valign="top">Tipo</td>
        <td valign="top">Funcion&aacute;rio</td>
        <td valign="top">Data</td>
        <td valign="top">Ficheiro</td>
     </tr>
    <?php
            $Qur = "SELECT dnc_Doc AS NAME, dnc_ID AS ID FROM hd_doctipos WHERE dnc_Country = {$__sys['Country']} AND dnc_Activo = 1";
            $AMLDocs = $GLOBALS['MYT']->db_array("SELECT * FROM hd_docdocumentos
	  		INNER JOIN hd_doctipos ON dnc_ID = dnl_TipoDoc
			INNER JOIN systemoffice.main_users ON ref =  dnl_Usuario
	   WHERE dnl_AML = {$AMHID}");
            for ($d = 1; $d <= $AMLDocs[0]; $d++) {
                echo '<tr bgcolor="' . gridlines($d) . '">
        <td NOWRAP>';
                mn_field('select', 'ED', 'dnl_TipoDoc', $AMLDocs[$d]['dnl_TipoDoc'], $Qur, '', '', '" onchange="
               if(\''.substr($SESSST,1,1).'\'==\'A\'){
		document.MQuery.OBJCT_TYPE.value=this.value;
		document.MQuery.OBJCT_ID.value=' . $AMLDocs[$d]['dnl_ID'] . ';
		document.MQuery.action=\'_response/call.php?get=Compliance/doc_pract1\';
		subform(\'MQuery\',\'Doc_ActionED\');
               }');
                echo '</td>
        <td NOWRAP>' . $AMLDocs[$d]['name'] . '</td>
        <td NOWRAP>' . $AMLDocs[$d]['dnl_FechaEntrega'] . '</td>
        <td NOWRAP>
        <img alt="Ver" src="_response/bin.php?get=view.png" onclick="modalwindow(\'Pre-visualizacao\',\'_response/call.php?get=Compliance/amh_docview&RSID=' . $AMLDocs[$d]['dnl_FILE'] . '&ID=' . $AMLDocs[$d]['dnl_ID'] . '&RSIF=' . $AMLDocs[$d]['dnl_CL'] . '\',905,500);">
        <img alt="Imprimir" src="_response/bin.php?get=print.png">
	<img alt="Editar" src="_response/bin.php?get=edit.png" onclick="modalwindow(\'Pre-visualizacao\',\'_response/call.php?get=Compliance/amh_docedit&RSID=' . $AMLDocs[$d]['dnl_FILE'] . '&RSIF=' . $AMLDocs[$d]['dnl_CL'] . '\',500,500);">';
    if(substr($SESSST,1,1)=='A'){
        echo '<img alt="Apagar" src="_response/bin.php?get=dele.png" onclick="
        document.MQuery.OBJCT_ID.value=' . $AMLDocs[$d]['dnl_ID'] . ';
        document.MQuery.action=\'_response/call.php?get=Compliance/doc_pract1&AMHDOC_ID='.$AMLDocs[$d]['dnl_ID'].'\';
        subform(\'MQuery\',\'DocView\');">';
    }
        echo '</td>
  </tr>';
            } ?>
</table>